package com.curtain.sell.dto;

import com.curtain.sell.dataobject.OrderDetail;
import com.curtain.sell.enums.OrderStatusEnum;
import com.curtain.sell.enums.PayStatusEnum;
import com.curtain.sell.utils.serializer.DateLongSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
//如果有字段为NULL 则不要返回
//@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)  //2.3
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDTO {

    //订单id
    private String orderId;

    //买家名字
    private String buyerName;

    //买家手机号
    private String buyerPhone;

    //买家地址
    private String buyerAddress;

    //买家微信Openid
    private String buyerOpenid;

    //订单总金额
    private BigDecimal orderAmount;

    //订单状态  默认为0 新下单
    private Integer orderStatus = OrderStatusEnum.NEW.getCode();

    //支付状态  默认为0 未支付
    private Integer payStatus = PayStatusEnum.WAIT.getCode();

    //创建时间
    @JsonSerialize(using = DateLongSerializer.class)
    private Date createTime;

    //更新时间
    @JsonSerialize(using = DateLongSerializer.class)
    private Date updateTime;

    //一个订单  对应多件商品
    //new ArrayList 这样避免了返回给的前端是null 而是为[]  其他类型也是一样可以通过赋初值
    private List<OrderDetail> orderDetailList = new ArrayList<>();
}
